package web.suzy.oj.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * YangSuzy 软件工作室
 * 类名: MyMetaObjectConfig
 * 描述: ---- 待定 -----
 * 功能: 处理mybatis-plus自动填充时间
 *
 * @author YangSuzy
 * Date: 2022/11/17 12:15
 */
@Component
public class MyMetaObjectConfig implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime",new Date(),metaObject);
        this.setFieldValByName("modifiedTime",new Date(),metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("modifiedTime", new Date(), metaObject);
    }
}
